package com.mcxx.modules.miniSalvation.order.service.read;

import cn.hutool.core.date.DateUtil;
import com.mcxx.modules.base.utils.QueryParamUtil;
import com.mcxx.modules.miniSalvation.family.dto.SalvationObjectDTO;
import com.mcxx.modules.miniSalvation.family.param.SalvationObjectParam;
import com.mcxx.modules.miniSalvation.order.dao.read.OrderCaregiversReadDao;
import com.mcxx.modules.miniSalvation.order.dto.OrderCaregiversDTO;
import com.mcxx.modules.miniSalvation.order.dto.OrderSuspendCareDTO;
import com.mcxx.modules.miniSalvation.order.entity.OrderCaregiversEntity;
import com.mcxx.modules.miniSalvation.order.param.CaregiverParam;
import com.mcxx.util.CommonUtil;
import com.mcxx.util.Constant;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
@TaTransactional(readOnly = true)
public class OrderCaregiversReadService {

    @Autowired
    private OrderCaregiversReadDao orderCaregiversReadDao;


    public OrderCaregiversEntity getById(String id) {
    	return orderCaregiversReadDao.getById(id);
    }


    public Page getSalvationObjectList(CaregiverParam param, PageParam pageParam, UserAccountVo accountVo) {

        QueryParamUtil.setBaseParamValue(param,accountVo);

        param.setSendMonth(com.mcxx.util.DateUtil.getMonthString());

        orderCaregiversReadDao.beginPager(pageParam);
        List<SalvationObjectDTO> list = orderCaregiversReadDao.getSalvationObjectList(param);


        return orderCaregiversReadDao.endPager(list);
    }

    public Page listSalvationObject4Alteration(CaregiverParam param, PageParam pageParam, UserAccountVo accountVo) {

        QueryParamUtil.setBaseParamValue(param,accountVo);
        param.setSendMonth(com.mcxx.util.DateUtil.getMonthString());

        orderCaregiversReadDao.beginPager(pageParam);
        List<SalvationObjectDTO> list = orderCaregiversReadDao.listSalvationObject4Alteration(param);


        return orderCaregiversReadDao.endPager(list);
    }


    public OrderCaregiversDTO getCaregiverById(String id,String memberId) {
        return orderCaregiversReadDao.getCaregiverById(id,memberId);
    }


    public List<SalvationObjectDTO> getCareGiverInfo(CaregiverParam param, UserAccountVo accountVo) {

        QueryParamUtil.setBaseParamValue(param,accountVo);
        String curMonth = DateUtil.beginOfMonth(new Date()).toString("yyyyMM");
        param.setSendMonth(curMonth);
        return orderCaregiversReadDao.getCareGiverInfo(param);


    }


    public Double getCareGiverCountSummary(CaregiverParam param, UserAccountVo accountVo) {

        QueryParamUtil.setBaseParamValue(param,accountVo);
        String curMonth = DateUtil.beginOfMonth(new Date()).toString("yyyyMM");
        param.setSendMonth(curMonth);
        return orderCaregiversReadDao.getCareGiverCountSummary(param);
    }


    public OrderCaregiversDTO getCaregiverByIdcard(String idcard) {
        return orderCaregiversReadDao.getCaregiverByIdcard(idcard);
    }


    public Page getSuspendObjectList(CaregiverParam param, PageParam pageParam, UserAccountVo accountVo) {

        QueryParamUtil.setBaseParamValue(param,accountVo);

        param.setSendMonth(com.mcxx.util.DateUtil.getMonthString());

        orderCaregiversReadDao.beginPager(pageParam);
        List<SalvationObjectDTO> list = orderCaregiversReadDao.getSuspendObjectList(param);


        return orderCaregiversReadDao.endPager(list);
    }

}
